﻿using CPPEI.Coolzon.Common;
using CPPEI.Coolzon.Data;
using CPPEI.Coolzon.Service.Contract;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.Server.ServiceImplement
{
    public class ReqSwapAreaHandler : BaseHandler<ReqSwapAreaData, RespSwapAreaData>
    {
        public ReqSwapAreaHandler()
            : base(RESPONSE_SCENARIO.SCENE, RESPONSE_COMMAND.SCENE.SWAPAREA)
        {
        }

        protected override RespSwapAreaData OnHandle(Data.MainServiceData.Request request, ReqSwapAreaData requestData)
        {
            CacheData.ControlDomain domain = CacheData.ServerData.Instance.GetDomain(request.Header.DomainId);
            if (domain != null)
            {
                domain.UpdateViewState(domain.SolutionName, requestData.ViewStateAge, requestData.ViewStateToken);
            }

            RespSwapAreaData respSwapAreaData = new RespSwapAreaData();
            respSwapAreaData.Scene = requestData.Scene;
            respSwapAreaData.SourceArea = requestData.SourceArea;
            respSwapAreaData.DestArea = requestData.DestArea;
            return respSwapAreaData;
        }
    }
}
